:root {
  --uploader-action-background: #f7f8fa;
  --uploader-action-icon-color: #888;
  --uploader-action-icon-size: 24px;
  --uploader-action-margin: 0 10px 10px 0;
  --uploader-file-size: 80px;
  --uploader-file-margin: 0 10px 10px 0;
  --uploader-file-name-background: #f7f8fa;
  --uploader-file-name-color: #888;
  --uploader-file-name-font-size: 12px;
  --uploader-file-name-padding: 10px;
  --uploader-file-text-align: center;
  --uploader-file-border-radius: 0;
  --uploader-file-close-background: rgba(0, 0, 0, 0.3);
  --uploader-file-close-size: 24px;
  --uploader-file-close-icon-font-size: 14px;
  --uploader-file-close-icon-color: #fff;
  --uploader-file-cover-fit: cover;
  --uploader-file-cover-background: #f7f8fa;
  --uploader-preview-video-width: 100vw;
  --uploader-preview-video-height: 100vw;
  --uploader-file-indicator-height: 4px;
  --uploader-file-indicator-normal-color: var(--color-disabled);
  --uploader-file-indicator-success-color: var(--color-success);
  --uploader-file-indicator-error-color: var(--color-danger);
  --uploader-file-progress-color: var(--color-primary);
  --uploader-disabled-color: var(--color-disabled);
  --uploader-disabled-text-color: var(--color-text-disabled);
  --uploader-loading-background: linear-gradient(
    90deg,
    hsla(0, 0%, 100%, 0),
    hsla(0, 0%, 100%, 0.3),
    hsla(0, 0%, 100%, 0)
  );
}

@keyframes var-uploader-loading-animation {
  from {
    transform: translateX(-100%);
  }

  to {
    transform: translateX(100%);
  }
}

.var-uploader {
  width: 100%;

  &__file-list {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
  }

  &__file {
    position: relative;
    width: var(--uploader-file-size);
    height: var(--uploader-file-size);
    margin: var(--uploader-file-margin);
    border-radius: var(--uploader-file-border-radius);
    overflow: hidden;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }

  &__file-name {
    position: absolute;
    width: 100%;
    height: 100%;
    line-height: calc(var(--uploader-file-size) - var(--uploader-file-name-padding) * 2);
    font-size: var(--uploader-file-name-font-size);
    z-index: 0;
    background: var(--uploader-file-name-background);
    padding: var(--uploader-file-name-padding);
    color: var(--uploader-file-name-color);
    text-align: var(--uploader-file-text-align);
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
    user-select: none;
    transition: background-color 0.25s;
  }

  &__file-cover {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    background: var(--uploader-file-cover-background);
    object-fit: var(--uploader-file-cover-fit);
    pointer-events: none;
    transition: background-color 0.25s;
  }

  &__file-close {
    position: absolute;
    top: 0;
    right: 0;
    z-index: 2;
    border-top: var(--uploader-file-close-size) solid var(--uploader-file-close-background);
    border-left: var(--uploader-file-close-size) solid transparent;
  }

  &__file-close-icon[var-uploader-cover] {
    position: absolute;
    top: calc(-1 * var(--uploader-file-close-size));
    right: 0;
    font-size: var(--uploader-file-close-icon-font-size);
    color: var(--uploader-file-close-icon-color);
  }

  &__file-indicator {
    position: absolute;
    left: 0;
    bottom: 0;
    z-index: 2;
    width: 100%;
    height: var(--uploader-file-indicator-height);
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    background: var(--uploader-file-indicator-normal-color);
  }

  &__action {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--uploader-action-icon-color);
    width: var(--uploader-file-size);
    height: var(--uploader-file-size);
    background: var(--uploader-action-background);
    margin: var(--uploader-action-margin);
    border-radius: var(--uploader-file-border-radius);
    transition: background-color 0.25s;
    cursor: pointer;
  }

  &__action-icon[var-uploader-cover] {
    font-size: var(--uploader-action-icon-size);
  }

  &__action-input {
    display: block;
    width: 0;
    height: 0;
    visibility: hidden;
  }

  &__preview[var-uploader-cover] {
    background: #000;
    box-shadow: none;
  }

  &__preview-video {
    width: var(--uploader-preview-video-width);
    height: var(--uploader-preview-video-height);
  }

  &__progress {
    width: 0%;
    height: 100%;
    background-color: var(--uploader-file-progress-color);
    transition: all 0.25s ease-in-out;
  }

  &--loading {
    &::after {
      content: '';
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      z-index: 1;
      animation: var-uploader-loading-animation 0.6s infinite;
      background: var(--uploader-loading-background);
      transition: background-color 0.25s;
    }
  }

  &--success {
    background: var(--uploader-file-indicator-success-color);
  }

  &--error {
    background: var(--uploader-file-indicator-error-color);
  }

  &--disabled {
    background: var(--uploader-disabled-color);
    color: var(--uploader-disabled-text-color);
    cursor: not-allowed;
  }

  &--outline-none {
    outline: none;
  }
}
